package com.ghy.seckill.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ghy.seckill.entity.OmsOrderItem;
import com.ghy.seckill.service.OmsOrderItemService;
import com.ghy.seckill.mapper.OmsOrderItemMapper;
import com.ghy.seckill.vo.OrderVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
*
*/
@Service
public class OmsOrderItemServiceImpl extends ServiceImpl<OmsOrderItemMapper, OmsOrderItem>
implements OmsOrderItemService{
    @Autowired
    private OmsOrderItemMapper omsOrderItemMapper;
    @Override
    public Integer addOrder(OrderVo orderVo) {
        OmsOrderItem omsOrderItem=new OmsOrderItem();
        omsOrderItem.setOrderSn(orderVo.getOrderSn());
        omsOrderItem.setSkuId(orderVo.getSkuId());
        omsOrderItem.setSkuPic(orderVo.getSkuPic());
        omsOrderItem.setSkuPrice(orderVo.getSeckillPrice());
        omsOrderItem.setSkuQuantity(orderVo.getNum());
        int insert = omsOrderItemMapper.insert(omsOrderItem);
        return insert;
    }

    @Override
    public void closeOrder(String orderSn) {
        if (orderSn!=null){
            QueryWrapper queryWrapper=new QueryWrapper();
            queryWrapper.eq("order_sn",orderSn);
            omsOrderItemMapper.delete(queryWrapper);
        }

    }
}
